

#### APPENDIX C3: survival models

# load, combine data
library(rio)
library(tidyverse)

# estimate survival models
library(survival)

# generate tables
library(stargazer)



# LOAD DATA
survival_doc_df <- import("survival_doc_data.csv") %>%
  filter(iso3c!="TTO" & iso3c!="GUY" & iso3c!="SUR")

survival_fund_df <- import("survival_fund_data.csv") %>%
  filter(iso3c!="TTO" & iso3c!="GUY" & iso3c!="SUR")


## TABLE C5: ALL DOCS, FUNDS
cox1 <- coxph(Surv(start, stop, doc) ~ approval,
              data = survival_doc_df)

cox2 <- coxph(Surv(start, stop, doc) ~ opp1vote,
              data = survival_doc_df)

cox3 <- coxph(Surv(start, stop, doc) ~ number_protests,
              data = survival_doc_df)

cox4 <- coxph(Surv(start, stop, fund_doc) ~ approval,
              data = survival_fund_df)

cox5 <- coxph(Surv(start, stop, fund_doc) ~ opp1vote,
              data = survival_fund_df)

cox6 <- coxph(Surv(start, stop, fund_doc) ~ number_protests,
              data = survival_fund_df)


stargazer(cox1,cox2,cox3,cox4,cox5,cox6, #type="text",
          no.space = T,
          covariate.labels = c("Executive approval (perc)","Opposition vote share (perc)","Number of protests"), 
          dep.var.labels = c("Time until first document","Time until first fund document"))

